/**
 *
 * @author 	David Alvarez Lopez
 * @email 	sly.dekar@gmail.com
 * @date	25-Nov-2005
 *
 */

package com.dekaru.data;

import java.util.*;

public class Stack {

	private Vector<Object> vec;
	
	// ==================
	// CLASS CONSTRUCTORS
	// ==================
	
	public Stack() {
		this.vec = new Vector<Object>();
	}
	
	// =====================
	// ACTUAL IMPLEMENTATION
	// =====================
	
	public Object pop(){
		return vec.remove(vec.size()-1);
	}
	
	public void push(Object obj) {
		vec.add(obj);
	}
	
	// ====================
	// OTHER USEFUL METHODS
	// ====================
	
	public boolean isEmpty() {
		
		if (vec.size() == 0) {
			return true;
		} else {
			return false;
		}
	}
	
	public int size() {
		return vec.size();
	}
	
	public String toString() {
		
		String s = new String();
		for (int i = 0; i < vec.size(); i++) {
			s += vec.get(i).toString() + " - ";
		}
		return s;
	}
}
